﻿using UnityEngine;
using System.Collections;

public class camFollow : MonoBehaviour
{
	
GameObject[] heroes;
 public float camY = 50.0f;

	
	
	// Use this for initialization
	void Start ()
	{
	
	}
	
	// Update is called once per frame
	void Update ()
	{
		heroes = GameObject.FindGameObjectsWithTag("Player");
		if (heroes.Length > 0) {
			Vector3 center = new Vector3(0, 0, 0);
			foreach (GameObject h in heroes) {
				center += h.transform.position;
			}
			center /= heroes.Length;
			center.y = camY;
			transform.position = Vector3.Lerp(transform.position, center, 0.2f); //Higher value react faster
		}

	
	}
}
